package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("permissions/user")
public @caption("人员信息") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("srv_user") class SrvUser implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("su_id")    @primary  @notnull  @note("  ") Long suId;// 主键 非空     
	private @caption("授权商户") @column("su_host") @like    @notnull  @relate("$suHost") @RelateClass(SrvHost.class)  @note("  ") String suHost;// 非空     
 	private transient SrvHost $suHost;//关联对象[授权商户]
	private @caption("所属部门") @column("su_group")     @notnull  @relate("$suGroup") @RelateClass(SrvGroup.class)  @note("  ") Long suGroup;// 非空     
 	private transient SrvGroup $suGroup;//关联对象[组织部门]
	private @caption("登录帐号") @column("su_username")     @notnull  @note("  ") String suUsername;// 非空     
	private @caption("登录密码") @column("su_password")   @hidden   @notnull  @note("  ") String suPassword;// 非空     
	private @caption("真实姓名") @column("su_real_name")     @notnull  @note("  ") String suRealName;// 非空     
	private @caption("手机号码") @column("su_mobile")     @notnull  @note("  ") String suMobile;// 非空     
	private @caption("邮箱地址") @column("su_email")      @note("  ") String suEmail;//     
	private @caption("快捷方式") @column("su_shortcut") @like     @note("  ") String suShortcut;//     
	private @caption("添加时间") @column("su_add_time")      @note("  ") Date suAddTime;//     
	private @caption("最后登录时间") @column("su_last_time")      @note("  ") Date suLastTime;//     
	private @caption("最后登录IP") @column("su_last_ip")      @note("  ") String suLastIp;//     
	private @caption("状态") @column("su_status")     @notnull  @note(" 1:有效 0:无效  ") Short suStatus;// 非空 1:有效 0:无效     
	 
	//默认构造函数
	public SrvUser(){ 
	
	}
	
	//主键构造函数
	public SrvUser(Long id){
		this.suId = id;
	}
	
	/**所有字段构造函数 
	 SrvUser(
	 	Utils.getString("suHost")//授权商户 [非空]
	 	,Utils.getLong("suGroup")//所属部门 [非空]
	 	,Utils.getString("suUsername")//登录帐号 [非空]
	 	,Utils.getString("suPassword")//登录密码 [非空]
	 	,Utils.getString("suRealName")//真实姓名 [非空]
	 	,Utils.getString("suMobile")//手机号码 [非空]
	 	,Utils.getString("suEmail")//邮箱地址
	 	,Utils.getString("suShortcut")//快捷方式
	 	,Utils.getDate("suAddTime")//添加时间
	 	,Utils.getDate("suLastTime")//最后登录时间
	 	,Utils.getString("suLastIp")//最后登录IP
	 	,Utils.getShort("suStatus")//状态 [非空]
	 )
	**/
	public SrvUser(String suHost,Long suGroup,String suUsername,String suPassword,String suRealName,String suMobile,String suEmail,String suShortcut,Date suAddTime,Date suLastTime,String suLastIp,Short suStatus){
		this.suHost=suHost;
		this.suGroup=suGroup;
		this.suUsername=suUsername;
		this.suPassword=suPassword;
		this.suRealName=suRealName;
		this.suMobile=suMobile;
		this.suEmail=suEmail;
		this.suShortcut=suShortcut;
		this.suAddTime=suAddTime;
		this.suLastTime=suLastTime;
		this.suLastIp=suLastIp;
		this.suStatus=suStatus;
	}
	
	//设置非空字段
	public SrvUser setNotNull(String suHost,Long suGroup,String suUsername,String suPassword,String suRealName,String suMobile,Short suStatus){
		this.suHost=suHost;
		this.suGroup=suGroup;
		this.suUsername=suUsername;
		this.suPassword=suPassword;
		this.suRealName=suRealName;
		this.suMobile=suMobile;
		this.suStatus=suStatus;
		return this;
	}
	/** 编号 [非空]       **/
	public SrvUser suId(Long suId){
		this.suId = suId;
		this.setSeted(F.suId);
		return this;
	}
	/** 授权商户 [非空] [SrvHost]      **/
	public SrvUser suHost(String suHost){
		this.suHost = suHost;
		this.setSeted(F.suHost);
		return this;
	}
	/** 所属部门 [非空] [SrvGroup]      **/
	public SrvUser suGroup(Long suGroup){
		this.suGroup = suGroup;
		this.setSeted(F.suGroup);
		return this;
	}
	/** 登录帐号 [非空]       **/
	public SrvUser suUsername(String suUsername){
		this.suUsername = suUsername;
		this.setSeted(F.suUsername);
		return this;
	}
	/** 登录密码 [非空]       **/
	public SrvUser suPassword(String suPassword){
		this.suPassword = suPassword;
		this.setSeted(F.suPassword);
		return this;
	}
	/** 真实姓名 [非空]       **/
	public SrvUser suRealName(String suRealName){
		this.suRealName = suRealName;
		this.setSeted(F.suRealName);
		return this;
	}
	/** 手机号码 [非空]       **/
	public SrvUser suMobile(String suMobile){
		this.suMobile = suMobile;
		this.setSeted(F.suMobile);
		return this;
	}
	/** 邮箱地址        **/
	public SrvUser suEmail(String suEmail){
		this.suEmail = suEmail;
		this.setSeted(F.suEmail);
		return this;
	}
	/** 快捷方式        **/
	public SrvUser suShortcut(String suShortcut){
		this.suShortcut = suShortcut;
		this.setSeted(F.suShortcut);
		return this;
	}
	/** 添加时间        **/
	public SrvUser suAddTime(Date suAddTime){
		this.suAddTime = suAddTime;
		this.setSeted(F.suAddTime);
		return this;
	}
	/** 最后登录时间        **/
	public SrvUser suLastTime(Date suLastTime){
		this.suLastTime = suLastTime;
		this.setSeted(F.suLastTime);
		return this;
	}
	/** 最后登录IP        **/
	public SrvUser suLastIp(String suLastIp){
		this.suLastIp = suLastIp;
		this.setSeted(F.suLastIp);
		return this;
	}
	/** 状态 [非空]   1:有效 0:无效     **/
	public SrvUser suStatus(Short suStatus){
		this.suStatus = suStatus;
		this.setSeted(F.suStatus);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public SrvUser clone(){
		SrvUser clone = new SrvUser();
		clone.suHost=this.suHost;
		clone.suGroup=this.suGroup;
		clone.suUsername=this.suUsername;
		clone.suPassword=this.suPassword;
		clone.suRealName=this.suRealName;
		clone.suMobile=this.suMobile;
		clone.suEmail=this.suEmail;
		clone.suShortcut=this.suShortcut;
		clone.suAddTime=this.suAddTime;
		clone.suLastTime=this.suLastTime;
		clone.suLastIp=this.suLastIp;
		clone.suStatus=this.suStatus;
		return clone;
	}
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(SrvUser.M.class);
		Cache.clearValue(SrvUser.M.class);
		Cache.deleteObject(SrvUser.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(SrvUser.M.class);
		Cache.clearValue(SrvUser.M.class);
		Cache.deleteObject(SrvUser.class, id);
	}
	
	
	/**
	 * 根据ID取人员信息
	 * @param id
	 * @return
	 */
	public static @api SrvUser get(Long id){		
		return getSrvUserById(id);
	}
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.suId = id;
	}
	
	/**
	 * 获取所有人员信息
	 * @return
	 */
	public static @api List<SrvUser> list(Map params,Integer size){
		return getSrvUserList(params,size);
	}
	/**
	 * 获取人员信息分页
	 * @return
	 */
	public static @api Page<SrvUser> page(Integer page,Integer size,Map params){
		return getSrvUserPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取人员信息
	 * @param params
	 * @return
	 */
	public static @api SrvUser Get(Map params){
		return getSrvUser(params);
	}
	/**
	 * 获取人员信息数
	 * @return
	 */
	public static @api Long count(Map params){
		return getSrvUserCount(params);
	}
	/**
	 * 获取人员信息数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getSrvUserEval(eval,params);
	}
	/**
	 * 获取人员信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getSrvUserStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取人员信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getSrvUserStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取人员信息
	 * @param id
	 * @return
	 */
	public static @api SrvUser getSrvUserById(Long id){		
		return getSrvUserDao().getSrvUserById(id);
	}
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.suId;
	}
	
	
	/**
	 * 根据ID取人员信息的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		value = Cache.getValue(SrvUser.class, id);
		if(value==null){
			SrvUser srvUser = get(id);
			if(srvUser!=null){
				String strValue = srvUser.getSuHost$();
				if(!"SuHost".equals("SuHost"))
					strValue+="("+srvUser.getSuHost$()+")";
				if(!"SuHost".equals("SuRealName"))
					strValue+="("+srvUser.getSuRealName$()+")";
				Cache.setValue(SrvUser.class, id ,strValue);
				value = strValue;
			}else{
				Cache.setValue(SrvUser.class, id ,"{"+id+"}",30);
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getSuHost$();
		if(!"SuHost".equals("SuHost"))
			keyValue+="("+this.getSuHost$()+")";
		if(!"SuHost".equals("SuRealName"))
			keyValue+="("+this.getSuRealName$()+")";
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询人员信息对象
	 * @return
	 */
	public static @api SrvUser find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("suId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex+=" or su_host = '"+key.replaceAll("'", "''")+"'";
			strDefinex+=" or su_real_name = '"+key.replaceAll("'", "''")+"'";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return SrvUser.getSrvUser(params);
	}
	
	
	/**
	 * 根据关键字查询人员信息
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","su_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("suId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex+=" or su_host like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex+=" or su_real_name like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<SrvUser> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(SrvUser srvUser:list){
			Map map = new HashMap();
			map.put("key",srvUser.getSuId().toString());
			map.put("value", Utils.js(srvUser.getKeyValue()));
			if(bObject==true)
				map.put("object",srvUser);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有人员信息
	 * @return
	 */
	public static @api List<SrvUser> getSrvUserList(Map params,Integer size){
		return getSrvUserDao().getSrvUserList(params,0,size);
	}
	
	/**
	 * 获取人员信息分页
	 * @return
	 */
	public static @api Page<SrvUser> getSrvUserPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getSrvUserDao().getSrvUserPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取人员信息
	 * @param params
	 * @return
	 */
	public static @api SrvUser getSrvUser(Map params){
		return getSrvUserDao().getSrvUser(params);
	}
	
	/**
	 * 保存一个人员信息
	 * @param srvUser
	 * @return
	 */
	public static @api SrvUser saveSrvUser(SrvUser srvUser){
		return getSrvUserDao().saveSrvUser(srvUser);
	}
	
	/**
	 * 根据条件更新人员信息
	 * @param values
	 * @param params
	 */
	public static @api int updateSrvUserByConfirm(Map values, Map params){
		return getSrvUserDao().updateSrvUserByConfirm(values,params);
	}
	
	/**
	 * 修改一个人员信息
	 * @param srvUser
	 * @return
	 */
	public static @api int updateSrvUser(SrvUser srvUser){
		return getSrvUserDao().updateSrvUser(srvUser);
	}
	
	/**
	 * 更新人员信息非空字段
	 * @param srvUser
	 */
	public static @api int updateSrvUser$NotNull(SrvUser srvUser){
		return getSrvUserDao().updateSrvUser$NotNull(srvUser);
	}
	
	/**
	 * 获取人员信息数
	 * @return
	 */
	public static @api Long getSrvUserCount(Map params){
		return getSrvUserDao().getSrvUserCount(params);
	}
		
		
	/**
	 * 获取人员信息自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getSrvUserEval(String eval,Map params){
		return getSrvUserDao().getSrvUserEval(eval,params);
	}
	/**
	 * 获取人员信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getSrvUserStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getSrvUserDao().getSrvUserStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = SrvUser.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(SrvUser.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateSrvUser(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getSrvUserDao().updateSrvUserByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteSrvUser(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getSrvUserDao().deleteSrvUserByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getSrvUserDao().removeSrvUserById(id);
	}
	
	
	/**
	 * 保存人员信息对象
	 * @param params
	 * @return
	 */
	public SrvUser save(){
		if(this.getSuId()!=null)
			getSrvUserDao().updateSrvUser(this);
		else
			return getSrvUserDao().saveSrvUser(this);
		return this;
	}
	
	
	/**
	 * 更新人员信息对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getSrvUserDao().updateSrvUser$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getSrvUserDao().removeSrvUserById(this.getSuId());
		else
			getSrvUserDao().deleteSrvUserById(this.getSuId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getSrvUserDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getSuId(){
		if(this.suId!=null){
			return this.suId;
		}
		return this.suId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getSuId$(){
		String strValue="";
		 strValue=Utils.string(this.getSuId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setSuId$(String strValue){
		if(Utils.empty(strValue)){
			this.suId=null;
			return;
		}
	 	this.suId=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setSuId(Long suId){
		this.suId = suId;
		this.setSeted(F.suId);
	}
	
	
	
	
	/*******************************授权商户**********************************/	
	/**
	* 授权商户 [非空] [SrvHost]     
	**/
	public String getSuHost(){
		if(this.suHost!=null){
			return this.suHost;
		}
		return this.suHost;
	}
	/**
	* 获取授权商户格式化(toString)
	**/
	public String getSuHost$(){
		String strValue="";
			
		if(!Utils.empty(this.getSuHost())){
			List<com.distribute.framework.model.SrvHost> items = com.distribute.framework.model.SrvHost.getSrvHostList(Utils.add("definex","sh_id in ("+Utils.string(this.getSuHost()).replace("#","")+")"),-1);
			for(com.distribute.framework.model.SrvHost item1:items)
				strValue+="["+Utils.string(item1.getShName$())+"]";
		}
	 	 return strValue;
	}
	/**
	* 根据授权商户反格式化
	**/
	public void setSuHost$(String strValue){
		if(Utils.empty(strValue)){
			this.suHost=null;
			return;
		}
			
		String strIds = "";
		for(String strItem:strValue.split(",")){
			SrvHost item = SrvHost.find(strItem);
			if(item!=null){
				strIds+=(strIds.equals("")?"":",")+"#"+item.getShId()+"#";
			}
		}
		this.suHost = strIds;
	}
	
	/**
	* 授权商户 [非空] [SrvHost]     
	**/
	public void setSuHost(String suHost){
		this.suHost = suHost;
		this.setSeted(F.suHost);
	}
			
	/**
	* 获取授权商户列表
	**/ 			
 	public List<com.distribute.framework.model.SrvHost> get$suHost(){
		if(!Utils.empty(this.getSuHost())){
			return com.distribute.framework.model.SrvHost.getSrvHostList(Utils.add("definex","sh_id in ("+Utils.string(this.getSuHost()).replace("#","")+")"),-1);
		}else
			return new ArrayList();
	}
	
	
	
	
	/*******************************所属部门**********************************/	
	/**
	* 所属部门 [非空] [SrvGroup]     
	**/
	public Long getSuGroup(){
		if(this.suGroup!=null){
			return this.suGroup;
		}
		return this.suGroup;
	}
	/**
	* 获取所属部门格式化(toString)
	**/
	public String getSuGroup$(){
		String strValue="";
		if(this.getSuGroup()!=null){
				strValue+=Utils.string(SrvGroup.getKeyValue(this.getSuGroup()));
		}			
	 	 return strValue;
	}
	/**
	* 根据所属部门反格式化
	**/
	public void setSuGroup$(String strValue){
		if(Utils.empty(strValue)){
			this.suGroup=null;
			return;
		}
		SrvGroup item = SrvGroup.find(strValue);
		if(item!=null){
			this.suGroup = Utils.parseLong(item.getSgId());
		}
	}
	
	/**
	* 所属部门 [非空] [SrvGroup]     
	**/
	public void setSuGroup(Long suGroup){
		this.suGroup = suGroup;
		this.setSeted(F.suGroup);
	}
	
	
	
	
	/**
	* 获取关联对象[组织部门]
	**/	 			
 	public SrvGroup get$suGroup(){
 		if(this.$suGroup!=null)
 			return this.$suGroup;
 		com.distribute.framework.model.SrvGroup srvGroup = null;
		if(this.getSuGroup()!=null){
 			srvGroup = SrvGroup.get(this.getSuGroup());
 		}
 		return srvGroup;
	}
	/*******************************登录帐号**********************************/	
	/**
	* 登录帐号 [非空]      
	**/
	public String getSuUsername(){
		if(this.suUsername!=null){
			return this.suUsername;
		}
		return this.suUsername;
	}
	/**
	* 获取登录帐号格式化(toString)
	**/
	public String getSuUsername$(){
		String strValue="";
		 strValue=Utils.string(this.getSuUsername());
	 	 return strValue;
	}
	/**
	* 根据登录帐号反格式化
	**/
	public void setSuUsername$(String strValue){
		if(Utils.empty(strValue)){
			this.suUsername=null;
			return;
		}
	 	this.suUsername=strValue;
	}
	
	/**
	* 登录帐号 [非空]      
	**/
	public void setSuUsername(String suUsername){
		this.suUsername = suUsername;
		this.setSeted(F.suUsername);
	}
	
	
	
	
	/*******************************登录密码**********************************/	
	/**
	* 登录密码 [非空]      
	**/
	public String getSuPassword(){
		if(this.suPassword!=null){
			return this.suPassword;
		}
		return this.suPassword;
	}
	/**
	* 获取登录密码格式化(toString)
	**/
	public String getSuPassword$(){
		String strValue="";
		 strValue=Utils.empty(this.getSuPassword())?"":"******";
	 	 return strValue;
	}
	/**
	* 根据登录密码反格式化
	**/
	public void setSuPassword$(String strValue){
		if(Utils.empty(strValue)){
			this.suPassword=null;
			return;
		}
		 //此处未实现
		 this.suPassword=Utils.parseString(strValue);
	}
	
	/**
	* 登录密码 [非空]      
	**/
	public void setSuPassword(String suPassword){
		this.suPassword = suPassword;
		this.setSeted(F.suPassword);
	}
	
	
	
	
	/*******************************真实姓名**********************************/	
	/**
	* 真实姓名 [非空]      
	**/
	public String getSuRealName(){
		if(this.suRealName!=null){
			return this.suRealName;
		}
		return this.suRealName;
	}
	/**
	* 获取真实姓名格式化(toString)
	**/
	public String getSuRealName$(){
		String strValue="";
		 strValue=Utils.string(this.getSuRealName());
	 	 return strValue;
	}
	/**
	* 根据真实姓名反格式化
	**/
	public void setSuRealName$(String strValue){
		if(Utils.empty(strValue)){
			this.suRealName=null;
			return;
		}
	 	this.suRealName=strValue;
	}
	
	/**
	* 真实姓名 [非空]      
	**/
	public void setSuRealName(String suRealName){
		this.suRealName = suRealName;
		this.setSeted(F.suRealName);
	}
	
	
	
	
	/*******************************手机号码**********************************/	
	/**
	* 手机号码 [非空]      
	**/
	public String getSuMobile(){
		if(this.suMobile!=null){
			return this.suMobile;
		}
		return this.suMobile;
	}
	/**
	* 获取手机号码格式化(toString)
	**/
	public String getSuMobile$(){
		String strValue="";
		 strValue=Utils.string(this.getSuMobile());
	 	 return strValue;
	}
	/**
	* 根据手机号码反格式化
	**/
	public void setSuMobile$(String strValue){
		if(Utils.empty(strValue)){
			this.suMobile=null;
			return;
		}
	 	this.suMobile=strValue;
	}
	
	/**
	* 手机号码 [非空]      
	**/
	public void setSuMobile(String suMobile){
		this.suMobile = suMobile;
		this.setSeted(F.suMobile);
	}
	
	
	
	
	/*******************************邮箱地址**********************************/	
	/**
	* 邮箱地址       
	**/
	public String getSuEmail(){
		if(this.suEmail!=null){
			return this.suEmail;
		}
		return this.suEmail;
	}
	/**
	* 获取邮箱地址格式化(toString)
	**/
	public String getSuEmail$(){
		String strValue="";
		 strValue=Utils.string(this.getSuEmail());
	 	 return strValue;
	}
	/**
	* 根据邮箱地址反格式化
	**/
	public void setSuEmail$(String strValue){
		if(Utils.empty(strValue)){
			this.suEmail=null;
			return;
		}
	 	this.suEmail=strValue;
	}
	
	/**
	* 邮箱地址       
	**/
	public void setSuEmail(String suEmail){
		this.suEmail = suEmail;
		this.setSeted(F.suEmail);
	}
	
	
	
	
	/*******************************快捷方式**********************************/	
	/**
	* 快捷方式       
	**/
	public String getSuShortcut(){
		if(this.suShortcut!=null){
			return this.suShortcut;
		}
		return this.suShortcut;
	}
	/**
	* 获取快捷方式格式化(toString)
	**/
	public String getSuShortcut$(){
		String strValue="";
		strValue=Utils.string(this.getSuShortcut());
	 	 return strValue;
	}
	/**
	* 根据快捷方式反格式化
	**/
	public void setSuShortcut$(String strValue){
		if(Utils.empty(strValue)){
			this.suShortcut=null;
			return;
		}
		//此处未实现
		this.suShortcut=Utils.parseString(strValue);
	}
	
	/**
	* 快捷方式       
	**/
	public void setSuShortcut(String suShortcut){
		this.suShortcut = suShortcut;
		this.setSeted(F.suShortcut);
	}
	
	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间       
	**/
	public Date getSuAddTime(){
		if(this.suAddTime!=null){
			return this.suAddTime;
		}
		return this.suAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getSuAddTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSuAddTime(),"yyyy-MM-dd"));
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setSuAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.suAddTime=null;
			return;
		}
	 	this.suAddTime=Utils.date(strValue,"yyyy-MM-dd");
	}
	
	/**
	* 添加时间       
	**/
	public void setSuAddTime(Date suAddTime){
		this.suAddTime = suAddTime;
		this.setSeted(F.suAddTime);
	}
	
	
	
	
	/*******************************最后登录时间**********************************/	
	/**
	* 最后登录时间       
	**/
	public Date getSuLastTime(){
		if(this.suLastTime!=null){
			return this.suLastTime;
		}
		return this.suLastTime;
	}
	/**
	* 获取最后登录时间格式化(toString)
	**/
	public String getSuLastTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSuLastTime(),"yyyy-MM-dd"));
	 	 return strValue;
	}
	/**
	* 根据最后登录时间反格式化
	**/
	public void setSuLastTime$(String strValue){
		if(Utils.empty(strValue)){
			this.suLastTime=null;
			return;
		}
	 	this.suLastTime=Utils.date(strValue,"yyyy-MM-dd");
	}
	
	/**
	* 最后登录时间       
	**/
	public void setSuLastTime(Date suLastTime){
		this.suLastTime = suLastTime;
		this.setSeted(F.suLastTime);
	}
	
	
	
	
	/*******************************最后登录IP**********************************/	
	/**
	* 最后登录IP       
	**/
	public String getSuLastIp(){
		if(this.suLastIp!=null){
			return this.suLastIp;
		}
		return this.suLastIp;
	}
	/**
	* 获取最后登录IP格式化(toString)
	**/
	public String getSuLastIp$(){
		String strValue="";
		 strValue=Utils.string(this.getSuLastIp());
	 	 return strValue;
	}
	/**
	* 根据最后登录IP反格式化
	**/
	public void setSuLastIp$(String strValue){
		if(Utils.empty(strValue)){
			this.suLastIp=null;
			return;
		}
	 	this.suLastIp=strValue;
	}
	
	/**
	* 最后登录IP       
	**/
	public void setSuLastIp(String suLastIp){
		this.suLastIp = suLastIp;
		this.setSeted(F.suLastIp);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:有效 0:无效    
	**/
	public Short getSuStatus(){
		if(this.suStatus!=null){
			return this.suStatus;
		}
		return this.suStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getSuStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSuStatus()),"1"))
			strValue=Utils.string("有效");		 
		 if(Utils.equals(Utils.string(this.getSuStatus()),"0"))
			strValue=Utils.string("无效");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setSuStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.suStatus=null;
			return;
		}
		 if(Utils.equals(strValue,"有效"))
		 	this.suStatus=Utils.parseShort("1");
		 if(Utils.equals(strValue,"无效"))
		 	this.suStatus=Utils.parseShort("0");
	}
	
	/**
	* 状态 [非空]   1:有效 0:无效    
	**/
	public void setSuStatus(Short suStatus){
		this.suStatus = suStatus;
		this.setSeted(F.suStatus);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	public String getSuName() {
		return this.getSuRealName();
	}
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(SrvUser.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(SrvUser.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(SrvUser.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(SrvUser.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(SrvUser.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${SrvUser.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvUser.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvUser.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(SrvUser.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${SrvUser.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvUser.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvUser.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(SrvUser.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M suId(Object suId){if(proxy)return proxy().suId(suId);  this.put("suId", suId);return this;};
	 	/** and su_id is null */
 		public M suIdNull(){if(proxy)return proxy().suIdNull();if(this.get("suIdNot")==null)this.put("suIdNot", "");this.put("suId", null);return this;};
 		/** not .... */
 		public M suIdNot(){if(proxy)return proxy().suIdNot();this.put("suIdNot", "not");return this;};
 		public M suIdNotNull(){if(proxy)return proxy().suIdNotNull();this.put("suIdNot", "not");this.put("suId", null);return this;};
 		public M suIdNot(Object suId){if(proxy)return proxy().suIdNot(suId);this.put("suIdNot", "not");this.put("suId", suId);return this;};
		/** and su_id <= ? */
		public M suIdMin(Object min){if(proxy)return proxy().suIdMin(min);this.put("suIdMin", min);return this;};
		/** and su_id >= ? */
		public M suIdMax(Object max){if(proxy)return proxy().suIdMax(max);this.put("suIdMax", max);return this;};
		public M suIdIn(String ids){
			if(proxy)return proxy().suIdIn(ids);  this.put("suIdIn", ids);return this;
		};	
		public M suHost$on(SrvHost.M value){if(proxy)return proxy().suHost$on(value);this.put("SuHost", value);value.put("on", "su_host");return this;};
		/** 授权商户 [非空] [SrvHost]      **/
		public M suHost(Object suHost){if(proxy)return proxy().suHost(suHost);  this.put("suHost", suHost);return this;};
	 	/** and su_host is null */
 		public M suHostNull(){if(proxy)return proxy().suHostNull();if(this.get("suHostNot")==null)this.put("suHostNot", "");this.put("suHost", null);return this;};
 		/** not .... */
 		public M suHostNot(){if(proxy)return proxy().suHostNot();this.put("suHostNot", "not");return this;};
 		public M suHostNotNull(){if(proxy)return proxy().suHostNotNull();this.put("suHostNot", "not");this.put("suHost", null);return this;};
 		public M suHostNot(Object suHost){if(proxy)return proxy().suHostNot(suHost);this.put("suHostNot", "not");this.put("suHost", suHost);return this;};
		public M suGroup$on(SrvGroup.M value){if(proxy)return proxy().suGroup$on(value);this.put("SuGroup", value);value.put("on", "su_group");return this;};
		/** 所属部门 [非空] [SrvGroup]      **/
		public M suGroup(Object suGroup){if(proxy)return proxy().suGroup(suGroup);  this.put("suGroup", suGroup);return this;};
	 	/** and su_group is null */
 		public M suGroupNull(){if(proxy)return proxy().suGroupNull();if(this.get("suGroupNot")==null)this.put("suGroupNot", "");this.put("suGroup", null);return this;};
 		/** not .... */
 		public M suGroupNot(){if(proxy)return proxy().suGroupNot();this.put("suGroupNot", "not");return this;};
 		public M suGroupNotNull(){if(proxy)return proxy().suGroupNotNull();this.put("suGroupNot", "not");this.put("suGroup", null);return this;};
 		public M suGroupNot(Object suGroup){if(proxy)return proxy().suGroupNot(suGroup);this.put("suGroupNot", "not");this.put("suGroup", suGroup);return this;};
		public M suGroupIn(String ids){
			if(proxy)return proxy().suGroupIn(ids);  this.put("suGroupIn", ids);return this;
		};	
		/** 登录帐号 [非空]       **/
		public M suUsername(Object suUsername){if(proxy)return proxy().suUsername(suUsername);  this.put("suUsername", suUsername);return this;};
	 	/** and su_username is null */
 		public M suUsernameNull(){if(proxy)return proxy().suUsernameNull();if(this.get("suUsernameNot")==null)this.put("suUsernameNot", "");this.put("suUsername", null);return this;};
 		/** not .... */
 		public M suUsernameNot(){if(proxy)return proxy().suUsernameNot();this.put("suUsernameNot", "not");return this;};
 		public M suUsernameNotNull(){if(proxy)return proxy().suUsernameNotNull();this.put("suUsernameNot", "not");this.put("suUsername", null);return this;};
 		public M suUsernameNot(Object suUsername){if(proxy)return proxy().suUsernameNot(suUsername);this.put("suUsernameNot", "not");this.put("suUsername", suUsername);return this;};
		/** 登录密码 [非空]       **/
		public M suPassword(Object suPassword){if(proxy)return proxy().suPassword(suPassword);  this.put("suPassword", suPassword);return this;};
	 	/** and su_password is null */
 		public M suPasswordNull(){if(proxy)return proxy().suPasswordNull();if(this.get("suPasswordNot")==null)this.put("suPasswordNot", "");this.put("suPassword", null);return this;};
 		/** not .... */
 		public M suPasswordNot(){if(proxy)return proxy().suPasswordNot();this.put("suPasswordNot", "not");return this;};
 		public M suPasswordNotNull(){if(proxy)return proxy().suPasswordNotNull();this.put("suPasswordNot", "not");this.put("suPassword", null);return this;};
 		public M suPasswordNot(Object suPassword){if(proxy)return proxy().suPasswordNot(suPassword);this.put("suPasswordNot", "not");this.put("suPassword", suPassword);return this;};
		/** 真实姓名 [非空]       **/
		public M suRealName(Object suRealName){if(proxy)return proxy().suRealName(suRealName);  this.put("suRealName", suRealName);return this;};
	 	/** and su_real_name is null */
 		public M suRealNameNull(){if(proxy)return proxy().suRealNameNull();if(this.get("suRealNameNot")==null)this.put("suRealNameNot", "");this.put("suRealName", null);return this;};
 		/** not .... */
 		public M suRealNameNot(){if(proxy)return proxy().suRealNameNot();this.put("suRealNameNot", "not");return this;};
 		public M suRealNameNotNull(){if(proxy)return proxy().suRealNameNotNull();this.put("suRealNameNot", "not");this.put("suRealName", null);return this;};
 		public M suRealNameNot(Object suRealName){if(proxy)return proxy().suRealNameNot(suRealName);this.put("suRealNameNot", "not");this.put("suRealName", suRealName);return this;};
		/** 手机号码 [非空]       **/
		public M suMobile(Object suMobile){if(proxy)return proxy().suMobile(suMobile);  this.put("suMobile", suMobile);return this;};
	 	/** and su_mobile is null */
 		public M suMobileNull(){if(proxy)return proxy().suMobileNull();if(this.get("suMobileNot")==null)this.put("suMobileNot", "");this.put("suMobile", null);return this;};
 		/** not .... */
 		public M suMobileNot(){if(proxy)return proxy().suMobileNot();this.put("suMobileNot", "not");return this;};
 		public M suMobileNotNull(){if(proxy)return proxy().suMobileNotNull();this.put("suMobileNot", "not");this.put("suMobile", null);return this;};
 		public M suMobileNot(Object suMobile){if(proxy)return proxy().suMobileNot(suMobile);this.put("suMobileNot", "not");this.put("suMobile", suMobile);return this;};
		/** 邮箱地址        **/
		public M suEmail(Object suEmail){if(proxy)return proxy().suEmail(suEmail);  this.put("suEmail", suEmail);return this;};
	 	/** and su_email is null */
 		public M suEmailNull(){if(proxy)return proxy().suEmailNull();if(this.get("suEmailNot")==null)this.put("suEmailNot", "");this.put("suEmail", null);return this;};
 		/** not .... */
 		public M suEmailNot(){if(proxy)return proxy().suEmailNot();this.put("suEmailNot", "not");return this;};
 		public M suEmailNotNull(){if(proxy)return proxy().suEmailNotNull();this.put("suEmailNot", "not");this.put("suEmail", null);return this;};
 		public M suEmailNot(Object suEmail){if(proxy)return proxy().suEmailNot(suEmail);this.put("suEmailNot", "not");this.put("suEmail", suEmail);return this;};
		/** 快捷方式        **/
		public M suShortcut(Object suShortcut){if(proxy)return proxy().suShortcut(suShortcut);  this.put("suShortcut", suShortcut);return this;};
	 	/** and su_shortcut is null */
 		public M suShortcutNull(){if(proxy)return proxy().suShortcutNull();if(this.get("suShortcutNot")==null)this.put("suShortcutNot", "");this.put("suShortcut", null);return this;};
 		/** not .... */
 		public M suShortcutNot(){if(proxy)return proxy().suShortcutNot();this.put("suShortcutNot", "not");return this;};
 		public M suShortcutNotNull(){if(proxy)return proxy().suShortcutNotNull();this.put("suShortcutNot", "not");this.put("suShortcut", null);return this;};
 		public M suShortcutNot(Object suShortcut){if(proxy)return proxy().suShortcutNot(suShortcut);this.put("suShortcutNot", "not");this.put("suShortcut", suShortcut);return this;};
		/** 添加时间        **/
		public M suAddTime(Object suAddTime){if(proxy)return proxy().suAddTime(suAddTime);  this.put("suAddTime", suAddTime);return this;};
	 	/** and su_add_time is null */
 		public M suAddTimeNull(){if(proxy)return proxy().suAddTimeNull();if(this.get("suAddTimeNot")==null)this.put("suAddTimeNot", "");this.put("suAddTime", null);return this;};
 		/** not .... */
 		public M suAddTimeNot(){if(proxy)return proxy().suAddTimeNot();this.put("suAddTimeNot", "not");return this;};
 		public M suAddTimeNotNull(){if(proxy)return proxy().suAddTimeNotNull();this.put("suAddTimeNot", "not");this.put("suAddTime", null);return this;};
 		public M suAddTimeNot(Object suAddTime){if(proxy)return proxy().suAddTimeNot(suAddTime);this.put("suAddTimeNot", "not");this.put("suAddTime", suAddTime);return this;};
 		/** and su_add_time >= ? */
 		public M suAddTimeStart(Object start){if(proxy)return proxy().suAddTimeStart(start);this.put("suAddTimeStart", start);return this;};			
 		/** and su_add_time <= ? */
 		public M suAddTimeEnd(Object end){if(proxy)return proxy().suAddTimeEnd(end);this.put("suAddTimeEnd", end);return this;};
		/** 最后登录时间        **/
		public M suLastTime(Object suLastTime){if(proxy)return proxy().suLastTime(suLastTime);  this.put("suLastTime", suLastTime);return this;};
	 	/** and su_last_time is null */
 		public M suLastTimeNull(){if(proxy)return proxy().suLastTimeNull();if(this.get("suLastTimeNot")==null)this.put("suLastTimeNot", "");this.put("suLastTime", null);return this;};
 		/** not .... */
 		public M suLastTimeNot(){if(proxy)return proxy().suLastTimeNot();this.put("suLastTimeNot", "not");return this;};
 		public M suLastTimeNotNull(){if(proxy)return proxy().suLastTimeNotNull();this.put("suLastTimeNot", "not");this.put("suLastTime", null);return this;};
 		public M suLastTimeNot(Object suLastTime){if(proxy)return proxy().suLastTimeNot(suLastTime);this.put("suLastTimeNot", "not");this.put("suLastTime", suLastTime);return this;};
 		/** and su_last_time >= ? */
 		public M suLastTimeStart(Object start){if(proxy)return proxy().suLastTimeStart(start);this.put("suLastTimeStart", start);return this;};			
 		/** and su_last_time <= ? */
 		public M suLastTimeEnd(Object end){if(proxy)return proxy().suLastTimeEnd(end);this.put("suLastTimeEnd", end);return this;};
		/** 最后登录IP        **/
		public M suLastIp(Object suLastIp){if(proxy)return proxy().suLastIp(suLastIp);  this.put("suLastIp", suLastIp);return this;};
	 	/** and su_last_ip is null */
 		public M suLastIpNull(){if(proxy)return proxy().suLastIpNull();if(this.get("suLastIpNot")==null)this.put("suLastIpNot", "");this.put("suLastIp", null);return this;};
 		/** not .... */
 		public M suLastIpNot(){if(proxy)return proxy().suLastIpNot();this.put("suLastIpNot", "not");return this;};
 		public M suLastIpNotNull(){if(proxy)return proxy().suLastIpNotNull();this.put("suLastIpNot", "not");this.put("suLastIp", null);return this;};
 		public M suLastIpNot(Object suLastIp){if(proxy)return proxy().suLastIpNot(suLastIp);this.put("suLastIpNot", "not");this.put("suLastIp", suLastIp);return this;};
		/** 状态 [非空]   1:有效 0:无效     **/
		public M suStatus(Object suStatus){if(proxy)return proxy().suStatus(suStatus);  this.put("suStatus", suStatus);return this;};
	 	/** and su_status is null */
 		public M suStatusNull(){if(proxy)return proxy().suStatusNull();if(this.get("suStatusNot")==null)this.put("suStatusNot", "");this.put("suStatus", null);return this;};
 		/** not .... */
 		public M suStatusNot(){if(proxy)return proxy().suStatusNot();this.put("suStatusNot", "not");return this;};
 		public M suStatusNotNull(){if(proxy)return proxy().suStatusNotNull();this.put("suStatusNot", "not");this.put("suStatus", null);return this;};
 		public M suStatusNot(Object suStatus){if(proxy)return proxy().suStatusNot(suStatus);this.put("suStatusNot", "not");this.put("suStatus", suStatus);return this;};
		public M suStatusIn(String ids){
			if(proxy)return proxy().suStatusIn(ids);  this.put("suStatusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有人员信息 **/
		public @api List<SrvUser> list(Integer size){			
			return getSrvUserList(this,size);
		}
		/** 获取人员信息分页 **/
		public @api Page<SrvUser> page(Integer page,Integer size){			
			return getSrvUserPage(page, size , this);
		}
		/** 根据查询条件取人员信息 **/
		public @api SrvUser get(){			
			return getSrvUser(this);
		}
		/** 获取人员信息数 **/
		public @api Long count(){			
			return getSrvUserCount(this);
		}
		/** 获取人员信息表达式 **/
		public @api <T> T eval(String strEval){			
			return getSrvUserEval(strEval,this);
		}
		/** 获取人员信息统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getSrvUserStats(this,sumKey,groupKey,dateType);
		}
		/** 获取人员信息统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getSrvUserStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateSrvUser(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteSrvUser(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String suId="suId";
		/** 授权商户 [非空] [SrvHost]      **/
		public final static @type(String.class) @like String suHost="suHost";
		/** 所属部门 [非空] [SrvGroup]      **/
		public final static @type(Long.class)  String suGroup="suGroup";
		/** 登录帐号 [非空]       **/
		public final static @type(String.class)  String suUsername="suUsername";
		/** 登录密码 [非空]       **/
		public final static @type(String.class)  String suPassword="suPassword";
		/** 真实姓名 [非空]       **/
		public final static @type(String.class)  String suRealName="suRealName";
		/** 手机号码 [非空]       **/
		public final static @type(String.class)  String suMobile="suMobile";
		/** 邮箱地址        **/
		public final static @type(String.class)  String suEmail="suEmail";
		/** 快捷方式        **/
		public final static @type(String.class) @like String suShortcut="suShortcut";
		/** 添加时间        **/
		public final static @type(Date.class)  String suAddTime="suAddTime";
	 	/** and su_add_time >= ? */
 		public final static @type(Date.class) String suAddTimeStart="suAddTimeStart";
 		/** and su_add_time <= ? */
 		public final static @type(Date.class) String suAddTimeEnd="suAddTimeEnd";
		/** 最后登录时间        **/
		public final static @type(Date.class)  String suLastTime="suLastTime";
	 	/** and su_last_time >= ? */
 		public final static @type(Date.class) String suLastTimeStart="suLastTimeStart";
 		/** and su_last_time <= ? */
 		public final static @type(Date.class) String suLastTimeEnd="suLastTimeEnd";
		/** 最后登录IP        **/
		public final static @type(String.class)  String suLastIp="suLastIp";
		/** 状态 [非空]   1:有效 0:无效     **/
		public final static @type(Short.class)  String suStatus="suStatus";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		suId("su_id"),
		suHost("su_host"),
		suGroup("su_group"),
		suUsername("su_username"),
		suPassword("su_password"),
		suRealName("su_real_name"),
		suMobile("su_mobile"),
		suEmail("su_email"),
		suShortcut("su_shortcut"),
		suAddTime("su_add_time"),
		suLastTime("su_last_time"),
		suLastIp("su_last_ip"),
		suStatus("su_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取人员信息数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = SrvUser.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = SrvUser.getSrvUser(params);
			else
				value = SrvUser.getSrvUserList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  SrvUser.where().suId(param).get();
		else if(!Utils.empty(param.toString()))
			value = SrvUser.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getSuId());
		Utils.fms(map,simple?"id":"suId",this.getSuId(),this.getSuId$());
		Utils.fms(map,simple?"host":"suHost",this.getSuHost(),this.getSuHost$());
		Utils.fms(map,simple?"group":"suGroup",this.getSuGroup(),this.getSuGroup$());
		Utils.fms(map,simple?"username":"suUsername",this.getSuUsername(),this.getSuUsername$());
		Utils.fms(map,simple?"password":"suPassword",this.getSuPassword(),this.getSuPassword$());
		Utils.fms(map,simple?"realName":"suRealName",this.getSuRealName(),this.getSuRealName$());
		Utils.fms(map,simple?"mobile":"suMobile",this.getSuMobile(),this.getSuMobile$());
		Utils.fms(map,simple?"email":"suEmail",this.getSuEmail(),this.getSuEmail$());
		Utils.fms(map,simple?"shortcut":"suShortcut",this.getSuShortcut(),this.getSuShortcut$());
		Utils.fms(map,simple?"addTime":"suAddTime",this.getSuAddTime(),this.getSuAddTime$());
		Utils.fms(map,simple?"lastTime":"suLastTime",this.getSuLastTime(),this.getSuLastTime$());
		Utils.fms(map,simple?"lastIp":"suLastIp",this.getSuLastIp(),this.getSuLastIp$());
		Utils.fms(map,simple?"status":"suStatus",this.getSuStatus(),this.getSuStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("suId",this.getSuId());
		map.put("suHost",this.getSuHost());
		map.put("suGroup",this.getSuGroup());
		map.put("suUsername",this.getSuUsername());
		map.put("suPassword",this.getSuPassword());
		map.put("suRealName",this.getSuRealName());
		map.put("suMobile",this.getSuMobile());
		map.put("suEmail",this.getSuEmail());
		map.put("suShortcut",this.getSuShortcut());
		map.put("suAddTime",this.getSuAddTime());
		map.put("suLastTime",this.getSuLastTime());
		map.put("suLastIp",this.getSuLastIp());
		map.put("suStatus",this.getSuStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static SrvUser fromMap(Map map){
		SrvUser srvUser = new SrvUser();
		srvUser.suId = Utils.parseLong(map.get("suId"));
		srvUser.suHost = Utils.parseString(map.get("suHost"));
		srvUser.suGroup = Utils.parseLong(map.get("suGroup"));
		srvUser.suUsername = Utils.parseString(map.get("suUsername"));
		srvUser.suPassword = Utils.parseString(map.get("suPassword"));
		srvUser.suRealName = Utils.parseString(map.get("suRealName"));
		srvUser.suMobile = Utils.parseString(map.get("suMobile"));
		srvUser.suEmail = Utils.parseString(map.get("suEmail"));
		srvUser.suShortcut = Utils.parseString(map.get("suShortcut"));
		srvUser.suAddTime = Utils.parseDate(map.get("suAddTime"));
		srvUser.suLastTime = Utils.parseDate(map.get("suLastTime"));
		srvUser.suLastIp = Utils.parseString(map.get("suLastIp"));
		srvUser.suStatus = Utils.parseShort(map.get("suStatus"));
		return srvUser;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(SrvUser old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/20088256422879677806.png";
	}
	public static String getIconfont(){
		return "icon-renshiguanli";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,SrvUser.M params){
		if(params==null)params=new SrvUser.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/permissions/user.edit.html?";
		if(params.get("suId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("suId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/permissions/user.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.suId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(SrvUser.ACT act,SrvUser.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",SrvUser.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(SrvUser.ACT act,SrvUser.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",SrvUser.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ISrvUserDao getSrvUserDao(){
		return Utils.getBean("srvUserDao");
	};
	
}